﻿#pragma once
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<Windows.h>
#include<locale.h>
#include<time.h>

#define WALL L'□'
#define BODY L'●'
#define FOOD L'★'

#define POS_X 24
#define POS_Y 12

enum DIRECTION
{
	UP=1,
	DOWN,
	LEFT,
	RIGHT
};
enum GAMESTATUS
{
	OK,
	END_NORMAL,
	KILL_BY_SELF,
	KILL_BY_WALL
};
typedef struct SnakeNode
{
	int x;
	int y;
	struct SnakeNode* next;
}SnakeNode,*pSnakeNode;

typedef struct Snake
{
	pSnakeNode _pSnake;
	pSnakeNode _pFood;
	enum DIRECTION _dir;
	enum GAMESTATUS _status;
	int _score;
	int _FoodWeight;
	int _SleepTime;
}Snake,*pSnake;

void GameStart(pSnake ps);

void WelcomeToGame();

void CreateMap();

void CreateFood(pSnake ps);

void SnakeInit(pSnake ps);

void GameRun(pSnake ps);

void pause();

void SnakeMove(pSnake ps);

int NextIsFood(pSnake ps,pSnakeNode pn);

void EatFood(pSnake ps, pSnakeNode pn);

void noFood(pSnake ps, pSnakeNode pn);